package com.wasp.collector.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class DateUtil {

    private static Logger logger = LoggerFactory.getLogger(DateUtil.class);
    public static final String longFormatter = "yyyy-MM-dd HH:mm:ss";
    public static final String longFormatterNumber = "yyyyMMddHHmmss";
	public static final String shortFormatter = "yyyy-MM-dd";
    public static String formatLongDate(Date d){
    	if(d!=null){
    		SimpleDateFormat format = new SimpleDateFormat(longFormatter);
    		return format.format(d);
    	}
    	return "";
    }
    public static String formatShortDate(Date d){
    	if(d!=null){
    		SimpleDateFormat format = new SimpleDateFormat(shortFormatter);
    		return format.format(d);
    	}
    	return "";
    }
    public static String formatLongDateWithNumber(Date d){
    	if(d!=null){
    		SimpleDateFormat format = new SimpleDateFormat(longFormatterNumber);
    		return format.format(d);
    	}
    	return "";
    }
    public static Date formatLongDate(String str){
		SimpleDateFormat format = new SimpleDateFormat(longFormatter);
		try {
			return format.parse(str);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
    }
}
